<?php
/**
 * Created by PhpStorm.
 * User: chenzhitao
 * Date: 2018/8/13
 * Time: 下午3:52
 */

namespace app\index\controller;


use think\Controller;
use think\Request;

class BaseController extends Controller
{
    public function __construct(Request $request)
    {
        parent::__construct();

        $pc_host = "https://".$_SERVER['SERVER_NAME'];
        $mobile_host = "https://m.qikuai100.com";
        $base_url = $request->baseUrl();
        $last_base_url_param = substr($base_url, -1);
        $is_mobile = isMobile();
        if($is_mobile){
            if($last_base_url_param == '/'){
                return $this->redirect($mobile_host.$base_url,'',302);
            }else{
                return $this->redirect($mobile_host.$base_url.'/','',302);
            }

        }
        if($last_base_url_param != '/'){
            return $this->redirect($pc_host.$base_url.'/','',301);
        }


    }

}